package screen

import (
	"math"
	"strings"
)

func (s *Screen) LogPrint() {
	x, y := s.ScreenObj.Size()
	LogStr := s.LogStr
	style := white
	switch s.LogType {
	case "INFO":
		LogStr = "  INFO:" + LogStr
		style = StyleLogInfo
	case "WARN":
		LogStr = "  WARN:" + LogStr
		style = StyleLogWarn
	case "ERROR":
		LogStr = "  ERROR:" + LogStr
		style = StyleLogError
	case "DEBUG":
		LogStr = "  DEBUG:" + LogStr
		style = StyleLogDebug
	default:
		LogStr = "  LOG:" + LogStr
	}
	LogStr = LogStr + strings.Repeat(" ", int(math.Max(0, float64(x-s.GetStrWidth(LogStr)))))
	s.EmitStr(0, y-1, style, LogStr)
}

func (s *Screen) LogInfo(LogStr string) {
	s.LogType = "INFO"
	s.LogStr = LogStr
}

func (s *Screen) LogDebug(LogStr string) {
	s.LogType = "DEBUG"
	s.LogStr = LogStr
}

func (s *Screen) LogError(LogStr string) {
	s.LogType = "ERROR"
	s.LogStr = LogStr
}

func (s *Screen) LogWarn(LogStr string) {
	s.LogType = "WARN"
	s.LogStr = LogStr
}
